export default function MapLoader() {
    return new Promise((resolve, reject) => {
        if (window.AMap) {
            resolve(window.AMap)
        } else {
            window._AMapSecurityConfig = {
                securityJsCode: '63a40a6e7bbd537b11b32a12f54ae8bc'
            }
            var script = document.createElement('script')
            script.type = 'text/javascript'
            script.async = true
            script.src =
                'https://webapi.amap.com/maps?v=1.4.15&key=0bea4e985dcc093557647a55c9270ee7&plugin=AMap.Geocoder,AMap.MouseTool,AMap.PolyEditor,AMap.Riding,AMap.Driving&callback=initAMap'
            script.onerror = reject
            document.head.appendChild(script)
        }
        window.initAMap = () => {
            resolve(window.AMap)
        }
    })
}
